Test Series - Data Structure

Test Number 66/115

Q: What are splay trees?
A. self adjusting binary search trees
B. self adjusting binary trees
C. a tree with strings
D. a tree with probability distributions
Solution: Splay trees are height balanced, self adjusting BST’s.
Q: Which of the following property of splay tree is correct?
A. it holds probability usage of the respective sub trees
B. any sequence of j operations starting from an empty tree with h nodes atmost, takes O(jlogh) time complexity
C. sequence of operations with h nodes can take O(logh) time complexity
D. splay trees are unstable trees
Solution: This is a property of splay tree that ensures faster access. we push the most recently used nodes to top which leads to faster access to recently used values.
Q: Why to prefer splay trees?
A. easier to program
B. space efficiency
C. easier to program and faster access to recently accessed items
D. quick searching
Solution: Whenever you insert an element or remove or read an element that will be pushed or stored at the top which facilitates easier access or recently used stuff.
Q:  Is it true that splay trees have O(logn) amortized complexity ?
A. true
B. false
C. 
D. 
Solution: We go with amortized time complexity when we feel that not all operations are worst and some can be efficiently done. in splay trees not all splay operations will lead to O(logn) worst case complexity.
Q: What is a splay operation?
A. moving parent node to down of child
B. moving a node to root
C. moving root to leaf
D. removing leaf node
Solution: Splay trees mainly work using splay operations. wheneve we insert, delete and search for a node we splay the respective nodes to root. we have zig-zag and zig-zig operations.
Q: Which of the following options is an application of splay trees?
A. cache Implementation
B. networks
C. send values
D. receive values
Solution: Splay trees can be used for faster access to recently accessed items and hence used for cache implementations.
Q: When we have red-black trees and AVL trees that can perform most of operations in logarithmic times, then what is the need for splay trees?
A. no there is no special usage
B. In real time it is estimated that 80% access is only to 20% data, hence most used ones must be easily available
C. redblack and avl are not upto mark
D. they are just another type of self balancing binary search trees
Solution: May be the stats showing 80-20% may be not accurate, but in real time that is the widely spread scenario seen. If you are into this type of situation, you must choose implementing splay trees.
Q: What output does the below pseudo code produces?

    Tree_node function(Tree_node x)
    {
        Tree_node y = x.left;
        x.left = y.right;
        y.right = x;
        return y;
    }
A. right rotation of subtree
B. left rotation of subtree
C. zig-zag operation
D. zig-zig operation
Solution: When a right rotation is done the parent of the rotating node becomes it’s right node and it’s child becomes it’s left child.
Q:  What is the disadvantage of using splay trees?
A. height of a splay tree can be linear when accessing elements in non decreasing order.
B. splay operations are difficult
C. no significant disadvantage
D. splay tree performs unnecessary splay when a node is only being read
Solution: This will be the case after accessing all n elements in non-decreasing order. Since the height of a tree corresponds to the worst-case access time, this means that the actual cost of an operation can be high. However the amortized access cost of this worst case is logarithmic O(log n).

You Have Score    /9